package com.echat.api.demo.serviceapi;

import com.echat.api.demo.serviceapi.betterCode.EchatTokenManager;

/**
 * Created by chenmohan on 2018/09/13
 *
 * @description 对应 com.echat.api.demo.serviceapi.betterCode.EchatTokenManager 的使用样例
 */
public class TokenManagerUseDemo {

    private static String currentToken = "";

    public static void main(String[] args) throws InterruptedException {

        EchatTokenManager tokenManager = new EchatTokenManager(
                null,      //远程服务的host
                "test",
                "123456",
                0,              //判断token即将过期的阈值(秒)
                5,                     //判断token是否即将过期的定时任务周期(秒)
                new EchatTokenManager.TokenNotify() {   //自定义回调接口
                    public void notify(String accessToken) {
                        currentToken = accessToken;
                    }
                });


        tokenManager.start();

        while (true){
            Thread.sleep(4500);
            System.out.println("当前token为: " + currentToken);

        }

       // tokenManager.accquireToken(); //获取accessToken
    }

}
